<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>增加修改</title>
<link rel="stylesheet" href="../../res/layui/css/layui.css">
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<form id="form" class="layui-form" action="../../listenMusicalType/updateoradd.action" method="post" style="margin-top: 10px;" enctype="multipart/form-data">
		<input type="hidden" name="mtId" id="mtId"/>
		<input type="hidden" name="isva" id="isva" value="1"/>
	 	<div class="layui-form-item" style="width:70%;">
	    <label class="layui-form-label">类型名称:</label>
		    <div class="layui-input-block">
		      <input name="mtName" lay-verify="mtName" autocomplete="off" placeholder="请输入类型名称" class="layui-input" type="text" id='mtName'>
		    </div>
	  	</div>
	  	<br/>
	  	
	  	
	 <br/>
	  <div class="layui-form-item" style="width:70%;">
	    <div class="layui-input-block">
	      <button class="layui-btn" lay-submit lay-filter="formDemo" id="sub" style="margin-left: 30px;">立即提交</button>
	    </div>
	   </div>
</form>
<script type="text/javascript" src="../../res/layui/layui.all.js" charset="utf-8"></script>

<script type="text/javascript">
layui.use(['form', 'layedit', 'laydate'], function(){
	  var form = layui.form
	  ,layer = layui.layer
	  ,layedit = layui.layedit
	  ,laydate = layui.laydate;
	  
	 
	  
	//日期
	  laydate.render({
	    elem: '#birthday'
	  });
	
	//创建一个编辑器
	  var editIndex = layedit.build('LAY_demo_editor');
	
	//自定义验证规则
	  form.verify({
		  number: function(value){
	      if(value.length == 0){
	        return '标题不能为空';
	      }
	    }
	    ,remark: function(value){
	      layedit.sync(editIndex);
	    }
	    ,name: function(value){
	    	if(value.length ==0){
	    		return '姓名不能为空';
	    	}else if(value.length>6){
	    		return '姓名不能大于6位';
	    	}
	    }
	    ,password: function(value){
	    	if(value.length ==0){
	    		return '密码不能为空';
	    	}else if(value.length<8){
	    		return '位数不能小于8';
	    	}else if(value.length>16){
	    		return '位数不能大于16';
	    	}
	    }
	  });
	
	  //监听提交
	  form.on('submit(formDemo)', function(data){
		  window.parent.location.reload()
		     var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		     parent.layer.close(index);//关闭当前页  
		  
	  });
});
	
function load() {
	 form.render();
}
</script>
</body>
</html>